﻿using B.S.Sterilizationcenter.Domain.yjb;
using B.S.Sterilizationcenter.Domain.zyy;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Appliaction.Commends.yjb;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Appliaction.CommandHandlers.yjb
{
    public class FantianConsumCommandHandlers : IRequestHandler<FantianConsumCommand, ApiResult<List<ConsumableMaterial>>>
    {
        private readonly ISqlSugarClient db;

        public FantianConsumCommandHandlers(ISqlSugarClient db)
        {
            this.db = db;
        }
        public Task<ApiResult<List<ConsumableMaterial>>> Handle(FantianConsumCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ConsumableMaterial>> result = new ApiResult<List<ConsumableMaterial>>();
            List<ConsumableMaterial> list = db.Queryable<ConsumableMaterial>().Where(o => o.ConsumableId == request.ConsumableId).ToList();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
